package com.grablist.feihu.grablist.ui.fragment.biz;

import com.grablist.feihu.grablist.base.BaseBean;
import com.grablist.feihu.grablist.base.BaseResp;
import com.grablist.feihu.grablist.base.BaseBiz;
import com.grablist.feihu.grablist.bean.ClueInfo;
import com.grablist.feihu.grablist.bean.UserInfo;
import com.grablist.feihu.grablist.comm.BaseSubscribe2;
import com.grablist.feihu.grablist.comm.RetrofitHelp;

import java.util.List;

import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

public class CustomClueBiz extends BaseBiz {
    /**
     * 获取用户信息
     *
     * @param
     * @param callback
     */
    public void getUserInfo(String token, final BaseBiz.Callback<List<UserInfo>> callback) {
        com.add(RetrofitHelp.getSecretApi().userInfoPage(token)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscribe2<BaseResp<List<UserInfo>>>() {

                    @Override
                    public void onSuccess(Object obj) {
                        callback.onSuccess((List<UserInfo>) obj);
                    }

                    @Override
                    public void onFailure(Object obj) {
                        callback.onFailure((List<UserInfo>) obj);
                    }
                })
        );
    }

    public void getBatchInfoByUserId(String userCode, Integer pageSize, Integer pageNum, final BaseBiz.Callback<BaseBean<List<ClueInfo>>> callback) {
        com.add(RetrofitHelp.getSecretApi().getBatchInfoByUserId(userCode, pageSize, pageNum, "", "", "")
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscribe2<BaseResp<BaseBean<List<ClueInfo>>>>() {
                    @Override
                    public void onSuccess(Object obj) {
                        callback.onSuccess((BaseBean<List<ClueInfo>>) obj);
                    }

                    @Override
                    public void onFailure(Object obj) {
                        callback.onFailure((BaseBean<List<ClueInfo>>) obj);
                    }
                })
        );
    }

}
